﻿using System;
using Might.Infrastructure.DOM;
using Might.Infrastructure.Events;

namespace Might.Infrastructure.Services {       
    
    public interface IProgressService {
        IProgressToken ProgressCreate(Type type, IDomNode iDomItem);
    }

    public interface IProgressToken {
    
        Type EventType { get; set; }
        IDomNode iDomItem { get; set; }
        ProgressEventArgs State { get; }
        
        event ProgressEventHandler ProgressGo;

        void ProgressStart(string p);
        void Progress(int percent, string info);
        void ProgressEnd(ProgressResult progressResult, string info);
    }


    public enum ProgressResult {
        Success,
        Timeout,
        BadArguments,
        Fail                
    }

    public class ProgressEventArgs : EventArgs {
        public int Percentage;
        public string UserState;

        public ProgressEventArgs(int percent, string state) {
            Percentage = percent;
            UserState = state;
        }
    }

    public class EndProgressEventArgs : ProgressEventArgs {
        public ProgressResult Result;

        public EndProgressEventArgs(int percent, string state, ProgressResult result)
            : base(percent, state) {
            Result = result;
        }
    }
}
